package com.yangming.springboot.deepin.redisConfig;

import com.alibaba.fastjson.JSON;
import com.yangming.springboot.deepin.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @创建人 ym
 * @创建时间 2021/3/30 0030
 * @描述
 **/

@Repository
public class UserRedis {

//    @Autowired
//    private RedisProperties redisProperties;//这里是注册一个redistemplate实例来着，不知道怎么用

    private Map<String, Object> map = new HashMap<String, Object>();

    public void add(String key, Long time, User user){
        map.put("key", key);
        map.put("user", JSON.toJSONString(user));
        map.put("time", time);
        map.put("timeUnit", TimeUnit.MINUTES);
    }

    public User get(String key){
        User user = null;
//        user = JSON.parseObject(map.get(key), User.class);
        return user;
    }

}
